
import { _decorator, Component, Node } from 'cc';
import yyComponent from '../../Script/Common/yyComponent';
import { EventType } from '../../Script/GameSpecial/GameEventType';
import { GlobalEnum } from '../../Script/GameSpecial/GlobalEnum';
const { ccclass, property } = _decorator;

@ccclass('GetGoldUI')
export class GetGoldUI extends yyComponent {

    protected onBtnGet() {
        this.playClickBtn();
        this.emit(EventType.Common.SDKEvent.showVideo, {
            success: this.onVideoFinish.bind(this),
        });
    }
    protected onVideoFinish() {
        this.emit(EventType.Common.UIEvent.playGoldAnim, {
            cb: () => {
                this.emit(EventType.Common.PlayerDataEvent.updatePlayerData, {
                    attribute: "gameData.asset.gold",
                    value: 500,
                    mode: "+",
                    emit: true,
                    save: true,
                });
                this.hideUI(GlobalEnum.UI.getGold);
            },
            gold: 500,
        });
    }
    protected onBtnClose() {
        this.playClickBtn();
        this.hideUI(GlobalEnum.UI.getGold);
    }
}

